package com.cocoiko.customview;

import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

import com.cocoiko.R;
import com.cocoiko.UserCocoiko;
import com.cocoiko.info.CocoikoInfo;

public class CocoikoListView extends ListView implements OnItemClickListener {

	Context context;

	CocoikoListAdapter adapter;
	ArrayList<CocoikoInfo> infos;

	public CocoikoListView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		this.context = context;
		this.setOnItemClickListener(this);
	}

	/*
	 * updateList
	 */
	public void addDataIntoList(ArrayList<CocoikoInfo> array) {
		this.infos = array;
		adapter = new CocoikoListAdapter(context, R.layout.cocoiko_list, array);
		this.setAdapter(adapter);
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long arg3) {
		// TODO Auto-generated method stub
		CocoikoInfo info = infos.get(position);
		Intent intent = new Intent(context, UserCocoiko.class);
		context.startActivity(intent);
		// on click item
	}

}
